@if(auth()->user()->id === 1)
    <div class="form-group">
        <label for="tagUid" class="col-md-3 control-label">所属用户</label>
        <div class="col-md-7">
            <select class="form-control" name="uid" id="tagUid"
                    onchange="$('#username').val($(this).find('option:selected').text());">
                @foreach ($userList as $id=>$name)
                    <option value="{{ $id }}" @if ($id === $uid) selected="selected" @endif>{{ $name }}</option>
                @endforeach
            </select>
            <input type="hidden" id="username" name="username" value="{{ empty($username) ? $userList[1] : $username}}">
        </div>
    </div>
@else
    <input type="hidden" id="uid" name="uid" value="{{auth()->user()->id}}">
    <input type="hidden" id="username" name="username" value="{{auth()->user()->name}}">
@endif
<div class="form-group">
    <label for="tagTitle" class="col-md-3 control-label">分组名称</label>
    <div class="col-md-7">
        <input type="text" class="form-control" name="title" id="tagTitle" value="{{ $title }}"
               @if (empty($template)) onblur="$('#template').val($('#tagTempId').find('option:selected').text())"
               @endif autofocus>
    </div>
</div>

<div class="form-group">
    <label for="tag" class="col-md-3 control-label">分组目录</label>
    <div class="col-md-7">
        <input type="text" class="form-control" name="directory" id="tag" value="{{ $directory }}">
    </div>
</div>

<hr>
<h2>推广页-设置访问条件限制：</h2>
<div class="form-group">
    <div class="col-md-12">
        <label for="station-type" class="col-md-3 control-label">站点类型<span
                    class="text-danger">*</span></label>
        <div class="col-md-7">
            <select class="form-control" id="station_type" name="station_type">
                @foreach(Config::get('app.station_type') as $key => $obj)
                    <option value="{{$key}}" @if($station_type == $key) selected @endif>{{$obj}}</option>
                @endforeach
            </select>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-12">
        <label for="station-type" class="col-md-3 control-label">设备选择<span
                    class="text-danger">&nbsp;</span></label>
        <div class="col-md-7">
            @foreach(Config::get('app.device_type') as $key => $obj)
                <label class="css-input css-radio css-radio-success push-10-r">
                    <input type="radio" name="device_type" value="{{$key}}"
                           @if($device_type == $key) checked @endif><span></span> {{$obj}}
                </label>
            @endforeach


        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-12">
        <label for="page-url" class="col-md-3 control-label">投放区域过滤<span
                    class="text-danger">*</span></label>
        <div class="col-md-7">
            <label class="css-input css-radio css-radio-success push-10-r">
                <input type="radio" name="area_config" value="0" @if($area_config == 0) checked="" @endif><span></span>
                关闭
            </label>

            <label class="css-input css-radio css-radio-success push-10-r">
                <input type="radio" name="area_config" value="2" @if($area_config == 2) checked="" @endif><span></span>
                选择不投放地区
            </label>

        </div>

    </div>
</div>
<div id="area-display" @if($area_config == 0)  style="display: none" @endif>
    <div class="form-group">
        <div class="col-md-12">
            <label class="col-md-3 control-label">不投放地区地区选择<span
                        class="text-danger">&nbsp;</span></label>
            <div class="col-md-7" id="select-area">

            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <label class="col-md-3 control-label">已选不投放地区<span
                        class="text-danger">&nbsp;</span></label>
            <div class="col-md-7" style="white-space:normal; " id="selected-area">

            </div>
        </div>
    </div>
	
	
</div>
<div class="form-group">
    <div class="col-md-12">
        <label for="page-url" class="col-md-3 control-label">渠道限制<span
                    class="text-danger">*</span></label>
        <div class="col-md-7">
            @foreach(Config::get('app.allow_channel') as $key => $obj)
                <label class="css-input css-checkbox-sm css-checkbox css-checkbox-success push-10-r">
                    <input class="channel" type="checkbox" name="allow{{$key}}" value="{{$key}}"
                           @foreach(explode(',',$channel) as $keyChannel => $objChannel)
                           @if($key == $objChannel) checked @endif
                            @endforeach
                    ><span></span> 允许{{$obj}}中访问
                </label>
            @endforeach
            <input id="channelValue" class="col-md-7" name="channel" value="{{$channel}}"
                   placeholder="格式:QQ,MicroMessenger,NewsArticle,">
        </div>

    </div>
</div>

{{--<div class="form-group">
	<div class="col-md-12">
		<label class="col-md-3 control-label">IP限制<span
					class="text-danger">&nbsp;</span></label>
		<div class="col-md-7" style="white-space:normal; " id="selected-area">
			<textarea class="col-md-7" name="ips">{{$ips}}</textarea>
		</div>
	</div>
</div>
<div class="form-group">
    <div class="col-md-12">
        <label class="col-md-3 control-label">投放时间<span
                    class="text-danger">&nbsp;</label>
        <div class="col-md-7" style="" id="selected-area">
            <input type="text" class='dv col-md-6' name="delivery_time" value='{{$delivery_time}}' readonly="readonly">&nbsp;&nbsp;<input onchange="setDt()" type="checkbox" id="dt_all">全选
            <div style="clear:both;"></div>
            <div >
                @foreach($delivery_times as $dt)
                    <input class="dt" onchange="delivery({{$dt}})" type="checkbox" value='{{$dt}}' @if(isset($delivery_value[$dt]))checked @endif>{{$dt}}@if($dt<10)&nbsp;&nbsp;@endif &nbsp;
                    @if($dt==11)<br/>@endif
                @endforeach
            </div>
        </div>
    </div>
</div>--}}

<hr>
<h2>设置-分组跳转：</h2>
<div class="form-group">
    <label for="tagGoToType" class="col-md-3 control-label">是否跳转</label>
    <div class="col-md-3">
        <select class="form-control" name="go_to_type" id="tagGoToType"
                onchange="$('#go_to_type_title').val($(this).find('option:selected').text());">
            @foreach (config('app.go_to_type') as $key => $name)
                <option value="{{ $key }}" @if ($key === $go_to_type) selected="selected" @endif>{{ $name }}</option>
            @endforeach
        </select>
        <input type="hidden" id="go_to_type_title" name="go_to_type_title"
               value="{{ empty($go_to_type_title) ? config('app.go_to_type')[1] : $go_to_type_title}}">
    </div>
</div>

<div class="form-group @if(!$go_to_type) hide @endif" id="TargetGidArea">
    <label for="tagTargetGid" class="col-md-3 control-label">跳转目标分组</label>
    <div class="col-md-3">
        <select class="form-control" name="target_gid" id="tagTargetGid">
            <option value="0">NULL</option>
            @foreach ($groupList as $gid=>$title)
                <option value="{{ $gid }}"
                        @if ($gid === $target_gid) selected="selected" @endif>{{ $title }}</option>
            @endforeach
        </select>

        <input type="hidden" id="target_gname" name="target_gname"
               value="{{ empty($target_gname) ? 'NULL' : $target_gname}}">
    </div>
</div>
<div id="TempateArea" class="@if($go_to_type) hide @endif">
    <div class="form-group">
        <label for="tagTempId" class="col-md-3 control-label">推广模板</label>
        <div class="col-md-3">
            <select class="form-control" name="tpl_id" id="tagTempId"
                    onchange="$('#template').val($(this).find('option:selected').text());">
                <option value="0">NULL</option>
                @foreach ($templateList as $tplKey=>$tplName)
                    <option value="{{ $tplKey }}"
                            @if ($tplKey === $tpl_id) selected="selected" @endif>{{ $tplName }}</option>
                @endforeach
            </select>
            <input type="hidden" id="template" name="template" value="{{$template}}">
        </div>
        <div class="col-md-3 "><a href="/admin/templates/create" class="control-label">添加模板</a></div>
    </div>
    <div class="form-group">
        <label for="tagTempId" class="col-md-3 control-label">审核页</label>
        <div class="col-md-3">
            <select class="form-control" name="sh_tpl_id" id="tagShTempId"
                    onchange="$('#sh_template').val($(this).find('option:selected').text());">
                <option value="0">NULL</option>
                @foreach ($templateList as $tplKey=>$tplName)
                    <option value="{{ $tplKey }}"
                            @if ($tplKey === $sh_tpl_id) selected="selected" @endif>{{ $tplName }}</option>
                @endforeach
            </select>
            <input type="hidden" id="sh_template" name="sh_template" value="{{$sh_template}}">
        </div>
        <div class="col-md-3 "><a href="/admin/templates/create" class="control-label">添加审核页</a></div>
    </div>
</div>
{{--#################The End################--}}
<hr>
<h2>选择推广微信号<span class="text-danger">*</span>&nbsp; <!--<input class="wechat" type="checkbox" name="wechat_list_all" id="wechat_list_all">--></h2>
			
<div class="form-group">
    <div class="col-md-12">
        <label for="page-url" class="col-md-3 control-label">
            <select class="form-control col-md-5" id="" onchange="showWG(this.value)">
				<option value="0">全部分组</option>
			  @foreach($wechatgroup as $v)
				<option value="{{$v['id']}}">{{$v['name']}}</option>
			   @endforeach
			</select>
        </label>
        <div class="col-md-7" id="wechatListAll">
			@foreach($wechatgroup as $v)
				<div id="fieldset_{{$v['id']}}" class="wg" style="border:1px solid #eee;margin-bottom:5px;padding:5px;border-radius:5px;">
					<input onchange="setW('w_{{$v['id']}}')" type="checkbox" id="w_{{$v['id']}}"><span>{{$v['name']}}</span><br/>
					@foreach($wechats as $wechat) 
						@if($wechat['group']==$v['id'])
						<input onchange="wechat()" class="wechat w_{{$v['id']}}" type="checkbox" name="wechat_list[]" value="{{$wechat['wx_num']}}"@foreach(explode(',',$wechat_list) as $keyWx => $objWx)@if($wechat['wx_num'] == $objWx) checked @endif @endforeach> {{$wechat['wx_num']}}&nbsp;&nbsp;&nbsp;
						@endif
					@endforeach
				</div>
			@endforeach
			<input type="hidden" name="wechat_list" value="{{$wechat_list}}"/>
			
            {{--@foreach($wechats as $key => $obj)
              
                    <input class="wechat" type="checkbox" name="wechat_list[]" value="{{$obj->wx_num}}"
                           @foreach(explode(',',$wechat_list) as $keyWx => $objWx)
                           @if($obj->wx_num == $objWx) checked @endif
                            @endforeach
                    ><span ></span>
                    <span title="随机值：{{$obj->max_rand}} 上线时间：{{$obj->online_time}} 下线时间：{{$obj->offline_time}}">
                        {{$obj->wx_num}}——<b  class="text-danger">{{$obj->wx_nike}}</b>
                    </span>
                
            @endforeach--}}

        </div>

    </div>
</div>
<hr>
@if(!empty($template))
    <div class="form-group">
        <label for="unCover" class="col-md-3 control-label">是否覆盖所在域名对应配置</label>
        <div class="col-md-7 radio">
            <label>
                <input type="radio" name="cover" id="unCover" value="unCover" checked="checked"> 不覆盖
            </label>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <label>
                <input type="radio" name="cover" id="cover" value="cover"> 覆盖
            </label>
        </div>
    </div>
@endif
@section('js')
    <link rel="stylesheet" href="//as.linwenfa.com/long/css/oneui.css">
    <script src="//as.linwenfa.com/long/js/area.js"></script>
    <script>

        var areas = [{!! $area_list !!}];
        $.areaSelect('#select-area', '#selected-area',areas);
        $(document).ready(function () {
            $('.channel').click(function () {
                var $channelValue = $("#channelValue").val();
                var $newValue = $(this).val() + ',';
                if ($(this).get(0).checked) {
                    $channelValue = $channelValue.replace($newValue, '');
                    $("#channelValue").val($channelValue + $newValue);
                } else {
                    $channelValue = $channelValue.replace($newValue, '');
                    $("#channelValue").val($channelValue);
                }
            });
            {{--var select_area_list = "{{$area_list}}";--}}
            {{--var select_city = select_area_list.spilt(',');--}}

            $('#station-type').change(function () {
                if ($(this).val() == 2) {
                    $('#weixinInfo').show();
                    $('input[name="allowweixin"]').prop('checked', true);
                } else {
                    $('#weixinInfo').hide();
                    $('input[name="allowweixin"]').prop('checked', false);
                }
            })
            $('#station-type').trigger('change');
        })
        $('input[name="area_config"]').click(function () {
            console.log($(this).val());
            if ($(this).val() != 0) {
                $('#area-display').show();
            } else {
                $('#area-display').css({'display': 'none'});
            }
        });

        //跳转分组
        $("#tagTargetGid").change(function () {
            $('#target_gname').val($(this).find('option:selected').text());
        });

        //是否跳转
        $("#tagGoToType").change(function () {
            if ($(this).val() == 0) {
                $("#TargetGidArea").removeClass('hide').hide();
                $("#tagTargetGid").val(0);
                $("#TempateArea").removeClass('hide').fadeIn('slow');
            } else {
                $("#TargetGidArea").removeClass('hide').fadeIn('slow');
                $("#TempateArea").removeClass('hide').hide();
                $("#tagTempId").val(0);
                $("#tagShTempId").val(0);
            }
        });

	//选中微信
	 function wechat(){
		var str = '';
		$(".wechat:checked").each(function(){
		   str+=this.value+','
		});
		str=str.substring(0,str.length-1);
		$('input[name=wechat_list]').val(str);
	}

	//选中微信分组
	function setW(c){
		$("."+c).prop("checked",$("#"+c).is(":checked"));
		wechat();
	}

	//选择显示微信分组
	function showWG(c){
		if(c==0){
			$(".wg").slideDown();
		}else{
			$(".wg").slideUp();
			$("#fieldset_"+c).slideDown();
		}
	}
    </script>
    <script src="//as.linwenfa.com/long/js/layer.js"></script>
    <script src="//as.linwenfa.com/long/js/station.editor.js"></script>
@endsection
